package com.bytedance.frameworks.baselib.network.http.util;

import inline.NetworkDemo;

public final class b {
    public char[] a;
    public int b;

    public b(int capacity) {
        if(capacity < 0) {
            throw new IllegalArgumentException("Buffer capacity may not be negative");
        }
        this.a = new char[capacity];
    }

    public final String a(int arg4, int arg5) {
        if(arg4 < 0) {
            throw new IndexOutOfBoundsException();
        }

        if(arg5 > this.b) {
            throw new IndexOutOfBoundsException();
        }

        if(arg4 > arg5) {
            throw new IndexOutOfBoundsException();
        }

        while(arg4 < arg5) {
            if(!NetworkDemo.a(this.a[arg4])) {
                break;
            }

            ++arg4;
        }

        while(arg5 > arg4) {
            if(!NetworkDemo.a(this.a[arg5 - 1])) {
                break;
            }

            --arg5;
        }

        return new String(this.a, arg4, arg5 - arg4);
    }

    public final void a(char arg4) {
        int v0 = this.b + 1;
        if(v0 > this.a.length) {
            this.a(v0);
        }

        this.a[this.b] = arg4;
        this.b = v0;
    }

    public final void a(int arg5) {
        char[] v0 = new char[Math.max(this.a.length << 1, arg5)];
        System.arraycopy(this.a, 0, v0, 0, this.b);
        this.a = v0;
    }

    public final void a(String arg6) {
        if(arg6 == null) {
            arg6 = "null";
        }

        int v0 = arg6.length();
        int v1 = this.b + v0;
        if(v1 > this.a.length) {
            this.a(v1);
        }

        arg6.getChars(0, v0, this.a, this.b);
        this.b = v1;
    }

    public final String toString() {
        return new String(this.a, 0, this.b);
    }

}

